package com.cloud.cmt.usermanage.service;

import com.cloud.cmt.usermanage.entity.Organization;
import com.cloud.cmt.usermanage.entity.vo.OrganizationDetailVO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.List;

/**
 * Created by Administrator on 2017/10/21.
 */
@RepositoryRestResource(path = "org")
public interface OrganizationRepository extends JpaRepository<Organization, Long> {
    List<Organization> findByUplink(Long uplink);
    OrganizationDetailVO findFirstById(Long id);
    @Query(value = "select o.* from organization o,employee e where o.manager = e.id and (org_name like %:value%  or e.name like %:value%) ", nativeQuery = true)
    List<Organization> orgByFilds(@Param("value") String value);
}
